var mysql = require("mysql");

var connection = mysql.createConnection({
  host: "127.0.0.1",
  user: "root",
  password: "root",
  database: "baixiu"
});

exports.login = (email, callback) => {
  // console.log("Model.login");
  // console.log(email);
  // 创建sql语句
  let sql = `select * from users where email = "${email}"`;
  connection.query(sql, (err, results) => {
    if (err) {
      callback(err);
    } else {
      // results返回一个查询的结果集
      callback(null, results[0]);
    }
  });
};
